package com.eclipse.training.ui;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;

import com.eclipse.training.ImagesRegistry;
import com.eclipse.training.model.AbstractUniverseElement;
import com.eclipse.training.model.Asteroid;
import com.eclipse.training.model.DarkMatter;
import com.eclipse.training.model.Galaxy;
import com.eclipse.training.model.GalaxyCluster;
import com.eclipse.training.model.Nebula;
import com.eclipse.training.model.Planet;
import com.eclipse.training.model.Satellite;
import com.eclipse.training.model.SolarSystem;
import com.eclipse.training.model.Star;
import com.eclipse.training.model.StarCluster;

public class UniverseTreeLabelProvider implements ILabelProvider {

	@Override
	public Image getImage(Object element) {
		if (element instanceof Asteroid) {
			return ImagesRegistry.getInstance()
					.get(ImagesRegistry.ICN_ASTEROID);
		} else if (element instanceof DarkMatter) {
			return ImagesRegistry.getInstance().get(
					ImagesRegistry.ICN_DARK_MATTER);
		} else if (element instanceof Galaxy) {
			return ImagesRegistry.getInstance().get(ImagesRegistry.ICN_GALAXY);
		} else if (element instanceof GalaxyCluster) {
			return ImagesRegistry.getInstance().get(
					ImagesRegistry.ICN_GALAXY_CLUSTER);
		} else if (element instanceof Nebula) {
			return ImagesRegistry.getInstance().get(ImagesRegistry.ICN_NEBULA);
		} else if (element instanceof Planet) {
			return ImagesRegistry.getInstance().get(ImagesRegistry.ICN_PLANET);
		} else if (element instanceof Satellite) {
			return ImagesRegistry.getInstance().get(
					ImagesRegistry.ICN_SATELLITE);
		} else if (element instanceof SolarSystem) {
			return ImagesRegistry.getInstance().get(
					ImagesRegistry.ICN_SOLAR_SYSTEM);
		} else if (element instanceof Star) {
			return ImagesRegistry.getInstance().get(ImagesRegistry.ICN_STAR);
		} else if (element instanceof StarCluster) {
			return ImagesRegistry.getInstance().get(
					ImagesRegistry.ICN_STAR_CLUSTER);
		}
		return null;
	}

	@Override
	public String getText(Object element) {
		if (element instanceof AbstractUniverseElement)
			return element.getClass().getSimpleName() + ": "
					+ ((AbstractUniverseElement) element).getName();
		return null;
	}

	@Override
	public void addListener(ILabelProviderListener listener) {

	}

	@Override
	public void dispose() {
	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
	}

}
